package demo;

import java.util.Scanner;

public class fac{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int num = sc.nextInt();
        int ret = facSum(num);
        System.out.println("这个整数的阶乘和为："+ret);
        sc.close();
    }
    public static int facSum(int n){
        int sum = 0;
        for(int i = 1;i<=n;i++){
            sum += fac(i);
        }
        return sum;
    }
    public static int fac(int n){
        int tmp = 1;
        for(int j = 1;j<=n;j++){
            tmp *= j;
        }
        return tmp;
    }
}
